package yunhe.dao.impl;

import yunhe.dao.UserDao;
import yunhe.entity.UserInfo;
import yunhe.factory.BaseConn;
import yunhe.util.NewsUtil;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class UserDaoImpl extends BaseConn implements UserDao {


	public int login(String nuName, String nuPass) {
		String MD5=NewsUtil.str2md5(nuName+nuPass);
		int re=-1;
		String sql="select nuid from n_user where nupass=?";
		PreparedStatement pst=(PreparedStatement) setParams(sql, new String[]{MD5}, 1);
		try {
			ResultSet rs=pst.executeQuery();
			if(rs.next()){
				re=rs.getInt(1);
			}
			else{
				re=-1;
			}
		} catch (SQLException e) {
			re=-1;
		}
		return re;
	}

	public UserInfo login(String MD5) {
		return null;
	}

}
